//
// Copyright (c) 2024 BPer
//
#include <bperrtp/BPerRtpRawPayload.h>
#include <bperutil/sys/BPerLog.h>
int32_t bPer_encode_h264_raw(BPerBuffer* buf,BPerRtpRawData* pkt){
	if (pkt->nb <= 0) {
			return BPer_Ok;
		}

		if (!bPer_buffer_require(buf,pkt->nb)) {
			return bPer_error_wrap(ERROR_RTC_RTP_MUXER, "requires %d bytes",pkt->nb);
		}

		bPer_write_bytes(buf,pkt->payload, pkt->nb);

		return BPer_Ok;
}
int32_t bPer_decode_h264_raw(BPerBuffer* buf,BPerRtpRawData* pkt){
	if (bPer_buffer_empty(buf)) {
		return BPer_Ok;
	}

	pkt->payload = buf->head;
	pkt->nb = bPer_buffer_left(buf);

	return BPer_Ok;
}

